<!--湖泊管理页面-->
<style lang="less" scoped>
.river {
  margin: 15px;
  .smallForm {
    display: inline-block;
  }
}
</style>

<template>
  <div class="river">
    <Card :bordered="false">
      <p slot="title"
         class="white">河湖管理 > <span class="select-font">湖泊管理</span>
      </p>
      <div>
        <Button type="primary"
                @click.native="addLake"
                style="margin-right:20px">新增湖泊水库</Button>
        <!-- <Button type="error"
                @click.native="del1"
                style="margin-right: 20px">删除湖泊水库</Button> -->
        <Form :model="searchItem"
              class="smallForm">
          <Input v-model="searchItem.name"
                 :maxlength="30"
                 style="width:200px;"
                 placeholder="请输入湖泊名称" />
        </Form>
        <Button type="info"
                style="margin-left:25px"
                @click="getData('1')">搜索</Button>
      </div>
    </Card>
    <div>
      <Table :data="lakeData"
             @on-selection-change="showSelect"
             :columns="lakeColumns"
             stripe></Table>
      <Page class="pull-right"
            :total="Page.total"
            :current="Page.current"
            :page-size="Page.pageSize"
            size="small"
            show-total
            @on-change="changePage"></Page>
    </div>
    <del-modal title="湖泊"
               ref="delModal"
               @del="del"
               :delArr="selectData"
               :url="urlLakeDel"></del-modal>
    <Modal v-model="editModal"
           :mask-closable="false"
           title="湖泊信息"
           width="1200">
      <i-col span="24"
             id="riverMessage">
        <Form ref="JForm"
              :model="lakeItem"
              :label-width="100"
              :rules="rules">
          <Form-item label="湖泊名称"
                     prop="river_name">
            <Input v-model="lakeItem.river_name"
                   :maxlength="15"
                   placeholder="请输入湖泊名称" />
          </Form-item>
          <Form-item label="湖泊编号"
                     prop="river_no">
            <Input v-model="lakeItem.river_no"
                   :maxlength="15"
                   placeholder="请输入湖泊编号" 
                   :disabled="isEdit" />
          </Form-item>
          <Form-item label="所属区"
                     prop="area">
            <Select v-model="lakeItem.area"
                    multiple>
              <Option v-for="item in areaArr"
                      :value="item.value"
                      :key="item.value">{{ item.title }}</Option>
            </Select>
          </Form-item>
          <Form-item label="所属镇"
                     prop="town">
            <Select v-model="lakeItem.town"
                    multiple>
              <Option v-for="item in townArr"
                      :value="item.name"
                      :key="item.name">{{ item.name }}</Option>
            </Select>
          </Form-item>
          <Form-item label="平均深度(m)"
                     prop="depth">
            <Input v-model="lakeItem.depth"
                   :maxlength="15"
                   placeholder="请输入平均深度"></Input>
          </Form-item>
          <Form-item label="水域面积(万m2)"
                     prop="acreage">
            <Input v-model="lakeItem.acreage"
                   :maxlength="15"
                   placeholder="请输入水域面积"></Input>
          </Form-item>
        </Form>
      </i-col>
      <i-col span="24">
        <Button type="primary"
                @click="clear_map"
                v-if="chongHui"
                class="btn_position">重绘</Button>
        <Button type="info"
                class="btn_position"
                @click="addRiver"
                v-if="!chongHui">下一段</Button>
        <Button class="btn_position2"
                v-if="!chongHui && !btnSave"
                @click="showMap(saveArr)">取消</Button>
        <Button class="btn_position2"
                v-if="btnSave"
                @click="clearMap">取消</Button>
        <div id="riverMap"
             style="width: 100%;height: 300px;">

        </div>
      </i-col>
      <div slot="footer">
        <Button v-if="btnSave"
                type="primary"
                @click="ok">保存</Button>
        <Button v-if="!btnSave"
                type="primary"
                @click="changeLake">修改</Button>
        <Button @click="editModal = false">取消</Button>
      </div>
    </Modal>
    <Modal v-model="history"
           :mask-closable="false"
           width="800">
      <div class="white"
           slot="header">河长调出历史</div>
      <Table :columns="columnsHistory"
             :data="dataHistory"></Table>
    </Modal>
    <!-- 删除湖泊 -->
    <Modal class="spe-modal"
           v-model="riverModal"
           :mask-closable="false"
           title="删除河流"
           width="800">
      <Upload type="drag"
              :format="['pdf']"
              :max-size="102400"
              :on-exceeded-size="handleMaxSize"
              :on-format-error="handleFormatError"
              :on-success="handleRiverSuccess"
              :on-error="handleError"
              :action="riverFileUrl" 
              ref="uploadRiver">
        <div style="padding: 20px 0">
          <Icon type="ios-cloud-upload"
                size="52"
                style="color: #3399ff"></Icon>
          <p>删除河湖数据，需上传PDF证明文件</p>
        </div>
      </Upload>
      <div slot="footer">
        <Button type="primary"
                @click="delRiver">保存</Button>
        <Button @click="hideRiverModal">取消</Button>
      </div>
    </Modal>
    <directories ref="directories"></directories>
  </div>
</template>

<script>
import { ajaxPost } from 'global/axios';
import { domain } from 'global/setting';
import storage from 'good-storage';
import delModal from 'components/public/delModal';
import directories from './directories';
let gm = 0;
let map1 = null;
let listener = null;
let listener2 = null;
export default {
  components: {
    'del-modal': delModal,
    directories,
  },
  data() {
    return {
      urlLakeList: '/bsi/riverchief/list',
      urlLakeDel: '/bsi/riverchief/del',
      urlLakeEdit: '/bsi/riverchief/edit',
      urlLakeNew: '/bsi/riverchief/new',
      townList: '/law/city/list',
      urlUserList: '/sys/userinfo/findbyrole',
      urlTreeList: '/sys/department/getTree',
      urlchrefList: '/bsi/riverchief/find',
      urlRouteEdit: '/waterenvir/bsiriver/typeadd',
      urlchrefNew: '/bsi/riverchief/addchief',
      urlchrefDel: '/bsi/riverchief/delchief',
      history: false,
      riverModal: false,
      riverFileUrl: '',
      columnsHistory: [
        {
          title: '河长名字',
          key: 'realname',
          align: 'center',
        },
        {
          title: '调任情况',
          key: 'remark',
          align: 'center',
        },
        {
          title: '河流名称',
          key: 'river_name',
          align: 'center',
        },
        {
          title: '调任方式',
          key: 'log_type',
          align: 'center',
        },
        {
          title: '调任时间',
          key: 'logdt',
          align: 'center',
        },
        {
          title: '职位',
          key: 'position',
          align: 'center',
        },
        {
          title: '河长等级',
          key: 'user_type',
          align: 'center',
        },
      ],
      dataHistory: [],
      searchItem: {
        name: '',
      },
      lakeData: [],
      rules: {
        river_name: [
          { required: true, message: '湖泊名不能为空', trigger: 'blur' },
        ],
        river_no: [
          { required: true, message: '湖泊编号不能为空', trigger: 'blur' },
        ],
        area: [
          {
            required: true,
            type: 'array',
            message: '请选择所属区',
            trigger: 'change',
          },
        ],
        town: [
          {
            required: true,
            type: 'array',
            message: '请选择所属镇',
            trigger: 'change',
          },
        ],
        depth: [
          { required: true, message: '平均深度不能为空', trigger: 'blur' },
        ],
        acreage: [
          { required: true, message: '水域面积不能为空', trigger: 'blur' },
        ],
      },
      lakeColumns: [
        {
          type: 'selection',
          width: 60,
          align: 'center',
          fixed: 'left',
        },
        {
          title: '湖泊名称',
          key: 'river_name',
        },
        {
          title: '湖泊编号',
          key: 'river_no',
        },
        {
          title: '所属区',
          key: 'area',
        },
        {
          title: '所属镇',
          key: 'town',
        },
        {
          title: '平均深度(m)',
          key: 'depth',
        },
        {
          title: '水域面积(万m2)',
          key: 'acreage',
        },
        {
          title: '操作',
          width: 280,
          render: (h, params) => {
            return h('div', [
              h(
                'Button',
                {
                  props: {
                    type: 'primary',
                    size: 'small',
                  },
                  style: {
                    marginRight: '5px',
                  },
                  on: {
                    click: () => {
                      this.edit(params.row);
                    },
                  },
                },
                '编辑'
              ),
              h(
                'Button',
                {
                  props: {
                    type: 'info',
                    size: 'small',
                  },
                  style: {
                    marginRight: '5px',
                  },
                  on: {
                    click: () => {
                      this.$refs.directories.edit(params.row);
                    },
                  },
                },
                '名录编辑'
              ),
              h(
                'Button',
                {
                  props: {
                    type: 'info',
                    size: 'small',
                  },
                  style: {
                    marginRight: '5px',
                  },
                  on: {
                    click: () => {
                      // this.$refs.directories.edit(params.row)
                      this.showHistory(params.row);
                    },
                  },
                },
                '调任历史'
              ),
              h(
                'Button',
                {
                  props: {
                    type: 'error',
                    size: 'small',
                  },
                  style: {
                    marginRight: '5px',
                  },
                  on: {
                    click: () => {
                      this.riverModal = true
                      this.riverFileUrl = `${domain}/filemanage/uploadpdf?dir=/river/strategy/${
                        params.row.river_no
                      }&token=${storage.session.get('token')}`;
                      this.delRiverData = {
                        _id: params.row._id,
                        files: []
                      }
                    },
                  },
                },
                '删除'
              ),
            ]);
          },
        },
      ],
      Page: {
        current: 1,
        pageSize: 14,
        total: 0,
      },
      selectData: [],
      actionPage: '1',
      lakeItem: {
        area: [],
        town: [],
      },
      editModal: false,
      btnSave: true,
      areaArr: [
        {
          title: '禅城区',
          value: '禅城区',
        },
        {
          title: '顺德区',
          value: '顺德区',
        },
        {
          title: '三水区',
          value: '三水区',
        },
        {
          title: '高明区',
          value: '高明区',
        },
        {
          title: '南海区',
          value: '南海区',
        },
      ],
      townArr: [],
      area: '',
      receiveData: [],
      areaArr1: [],
      chrefData: [],
      saveArr: [],
      chrefColumns: [
        {
          title: '名字',
          key: 'realname',
        },
        {
          title: '职位',
          key: 'position',
        },
        {
          title: '所属河长办',
          render: (h, params) => {
            return params.row.departments[0].name;
          },
        },
        {
          title: '角色',
          render: (h, params) => {
            return params.row.roles[0].rolename;
          },
        },
        {
          title: '操作',
          render: (h, params) => {
            return h(
              'Button',
              {
                props: {
                  type: 'error',
                  size: 'small',
                },
                on: {
                  click: () => {
                    this.delCherf(params.index);
                  },
                },
              },
              '删除'
            );
          },
        },
      ],
      chongHui: true,
      latArr_gcj02: [],
      bigArr_gcj02: [],
      saveRow: {},
      isEdit: false // 是否编辑
    };
  },
  methods: {
    getData(page = 1) {
      let params = {
        data: {
          page,
          pageSize: this.Page.pageSize,
          searchValue: { type: '湖泊水库' },
          order: { river_no: 1 },
          basis: 1,
        },
        url: this.urlLakeList,
        token: storage.session.get('token'),
        success: res => {
          this.$Loading.finish();
          this.lakeData = res.data.result.result;
          this.Page.total = res.data.result.totalSize;
        },
      };
      if (this.searchItem.name !== '') {
        params.data.searchValue.river_name = `${this.searchItem.name}|#|like`;
      }
      ajaxPost(params);
    },
    showSelect(data) {
      this.selectData = data; // 把勾选的数组存起来
    },
    changePage(page) {
      this.getData(page);
      this.actionPage = page;
    },
    // del1() {
    //   if (this.selectData.length > 0) {
    //     this.$refs.delModal.showModal();
    //   } else {
    //     this.$Message.warning('请选择湖泊');
    //   }
    // },
    del() {
      this.selectData = [];
      this.getData(this.actionPage);
    },
    edit(row) {
      this.isEdit = true;
      this.$refs.JForm.resetFields();
      this.saveRow = row;
      this.btnSave = false;
      this.lakeItem.river_name = row.river_name;
      this.lakeItem.river_no = row.river_no;
      this.lakeItem.depth = row.depth;
      this.lakeItem.acreage = row.acreage;
      this.lakeItem._id = row._id;
      this.bigArr_gcj02 = [];
      if (row.area !== '') {
        let data = row.area.split(',');
        this.lakeItem.area = data;
        this.getTown(data);
      }
      if (row.town !== '') {
        let data1 = row.town.split(',');
        this.lakeItem.town = data1;
      }
      let params = {
        data: {
          river_no: row.river_no,
        },
        url: this.urlchrefList,
        token: storage.session.get('token'),
        success: res => {
          this.$Loading.finish();
          this.chrefData = res.data.result.users;
          this.saveArr = res.data.result.river_geo;
          this.showMap(res.data.result.river_geo);
        },
      };
      this.editModal = true;

      ajaxPost(params);
    },

    showHistory(row) {
      let params = {
        data: {
          logdt: '2020-07-22 13:22:00',
          log_type: 'delete', //delete或add
          river_no: row.river_no, //河流编号
          river_name: row.river_name, //河流名
          type_name: '', //暂时忽略
          username: storage.session.get('username'), //用户名
          realname: storage.session.get('realname'), //用户姓名
          user_type: storage.session.get('user_type'), //用户类型
        },
        url: this.urlchrefList,
        token: storage.session.get('token'),
        success: res => {
          console.log(res);
          this.history = true;
          let result = res.data.result.transfer_logs;
          let list = [];
          result.map(item => {
            let obj = {};
            obj.realname = item.realname;
            obj.remark = item.remark;
            obj.river_name = item.river_name;
            obj.logdt = item.logdt;
            obj.log_type = item.log_type === 'add' ? '就任' : '离任';
            obj.user_type = this.getUserType(item.user_type);
            obj.position = item.position;
            list.push(obj);
          });
          this.dataHistory = list;
        },
      };
      ajaxPost(params);
    },

    getUserType(type) {
      let ty;
      switch (type) {
        case '0':
          ty = '村级河长';
          break;
        case '1':
          ty = '镇级河长';
          break;
        case '2':
          ty = '区级河长';
          break;
        case '3':
          ty = '市级河长';
          break;
        case '6':
        case '9':
          ty = '河长助理';
          break;
      }
      return ty;
    },

    addLake() {
      this.isEdit = false;
      this.clearMap();
      this.chongHui = false;
      this.btnSave = true;
      this.lakeItem = {
        river_name: '',
        river_no: '',
        area: [],
        town: [],
        depth: '',
        acreage: '',
        _id: '',
      };
      this.$refs.JForm.resetFields();
      this.editModal = true;
    },
    clearMap() {
      this.latArr_gcj02 = [];
      this.bigArr_gcj02 = [];
      let maps = document.getElementById('riverMap');
      maps.innerHTML = '';
      let center = new qq.maps.LatLng(23.009912294150357, 113.12484741210938);
      map1 = new qq.maps.Map(maps, {
        center,
        zoom: 10,
      });
      let path1 = [];
      listener = qq.maps.event.addListener(map1, 'click', event => {
        let cirle = new qq.maps.Circle({
          center: new qq.maps.LatLng(
            event.latLng.getLat(),
            event.latLng.getLng()
          ),
          radius: 4,
          fillColor: '#ff0000',
          map: map1,
        });
        path1.unshift(
          new qq.maps.LatLng(event.latLng.getLat(), event.latLng.getLng())
        );
        let polyline = new qq.maps.Polyline({
          path: path1,
          strokeColor: '#ff0000',
          strokeWeight: 3,
          editable: false,
          map: map1,
        });
        this.latArr_gcj02.push({
          lat: event.latLng.getLat(),
          lng: event.latLng.getLng(),
        });
      });
    },
    ok() {
      if (this.latArr_gcj02.length != 0) {
        this.bigArr_gcj02.push(this.latArr_gcj02);
      }
      let params = {
        data: {
          river_name: this.lakeItem.river_name,
          river_no: this.lakeItem.river_no,
          depth: this.lakeItem.depth,
          acreage: this.lakeItem.acreage,
          area: this.lakeItem.area.join(),
          town: this.lakeItem.town.join(),
          type: '湖泊水库',
          big_gcj02: this.bigArr_gcj02,
        },
        url: this.urlLakeNew,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code === '0000') {
            this.$Loading.finish();
            this.$Message.success({
              content: '新增成功',
            });
            this.editModal = false;
            this.getData(this.actionPage);
          } else {
            this.$Message.warning({
              content: res.data.message,
            });
          }
        },
      };
      ajaxPost(params);
    },
    changeLake() {
      if (this.latArr_gcj02.length != 0) {
        this.bigArr_gcj02.push(this.latArr_gcj02);
      }
      let params = {
        data: {
          river_name: this.lakeItem.river_name,
          river_no: this.lakeItem.river_no,
          depth: this.lakeItem.depth,
          acreage: this.lakeItem.acreage,
          area: this.lakeItem.area.join(),
          town: this.lakeItem.town.join(),
          _id: this.lakeItem._id,
          big_gcj02: this.bigArr_gcj02,
        },
        url: this.urlLakeEdit,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code === '0000') {
            this.$Loading.finish();
            this.$Message.success({
              content: '修改成功',
            });
            this.editModal = false;
            this.getData(this.actionPage);
          } else {
            this.$Message.warning({
              content: res.data.message,
            });
          }
        },
      };
      ajaxPost(params);
    },
    getTown(area) {
      let params = {
        data: {
          fieldName: ['name', 'level'],
          basis: 2,
          searchValue: {
            level: '3',
          },
        },
        url: this.townList,
        token: storage.session.get('token'),
        success: res => {
          this.$Loading.finish();
          this.townArr = res.data.result.result;
        },
      };
      let deps = JSON.parse(storage.session.get('department'));
      if (deps[0].level == '1') {
        params.data.searchValue.level2 = '';
        area.map((item, index) => {
          if (index == area.length - 1) {
            params.data.searchValue.level2 += `${item}|#|in`;
          } else {
            params.data.searchValue.level2 += `${item},`;
          }
        });
      }
      ajaxPost(params);
    },
    getReceive(dep) {
      let params = {
        data: {
          dep_name: dep,
        },
        url: this.urlUserList,
        token: storage.session.get('token'),
        success: res => {
          this.$Loading.finish();
          this.receiveData = res.data.result;
        },
      };
      ajaxPost(params);
    },
    getAddress() {
      let params = {
        data: {},
        url: this.urlTreeList,
        token: storage.session.get('token'),
        success: res => {
          this.areaArr1 = res.data.result;
        },
      };
      ajaxPost(params);
    },
    showMap(row) {
      this.chongHui = true;
      let maps = document.getElementById('riverMap');
      maps.innerHTML = '';
      let center = new qq.maps.LatLng(
        row[0].route_gcj02[0].lat,
        row[0].route_gcj02[0].lng
      );
      let map = new qq.maps.Map(maps, {
        center,
        zoom: 12,
      });
      row.map(item => {
        let path1 = [];
        for (let i = 0; i < item.route_gcj02.length; i++) {
          path1.push(
            new qq.maps.LatLng(item.route_gcj02[i].lat, item.route_gcj02[i].lng)
          );
        }
        let polyline = new qq.maps.Polyline({
          path: path1,
          strokeColor: '#FF0000',
          strokeWeight: 2,
          editable: false,
          map,
        });
      });
    },
    addChref() {
      if (this.lakeItem.chref_name === '') {
        this.$Message.warning({
          content: '请选择河长',
        });
        return;
      }
      let params = {
        data: {
          river_no: this.saveRow.river_no,
          username: this.lakeItem.chref_name,
        },
        url: this.urlchrefNew,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code == '0000') {
            this.$Loading.finish();
            this.$Message.success({
              content: '新增成功',
            });
            this.lakeItem.chref_name = '';
            this.area = [];
            this.receiveData.map(item => {
              item.users.map(items => {
                if (items.username == this.lakeItem.chref_name) {
                  this.chrefData.push(items);
                }
              });
            });
            this.edit(this.saveRow);
          } else {
            this.$Message.warning({
              content: res.data.message,
            });
          }
        },
      };
      ajaxPost(params);
    },
    delCherf(index) {
      let params = {
        data: {
          river_no: this.saveRow.river_no,
          username: this.chrefData[index].username,
        },
        url: this.urlchrefDel,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code == '0000') {
            this.$Loading.finish();
            this.$Message.success({
              content: '删除成功',
            });
            this.chrefData.splice(index, 1);
          } else {
            this.$Message.warning({
              content: res.data.message,
            });
          }
        },
      };
      ajaxPost(params);
    },
    //上传文件
    handleMaxSize(file) {
      this.$Notice.warning({
        title: '超出文件大小限制',
        desc: `文件太大，不能超过 100M。`,
      });
    },
    handleFormatError(file) {
      this.$Notice.warning({
        title: '文件格式不正确',
        desc: `文件格式不正确，请上传 pdf 格式。`,
      });
    },
    // 上传删除河流文件
    handleRiverSuccess(res) {
      console.log(res)
      let fileList = this.$refs.uploadRiver.fileList;
      if(this.delRiverData.files.length > 0){
        if(this.delRiverData.files.indexOf(res.result.path) !== -1){
          this.$Message.warning('不能上传两个相同的文件，请重新上传');
          this.$refs.uploadRiver.fileList.splice(-1, 1); // 删除最后一个元素
        }
      }
      // if(fileList.length > 1){
      //   this.$refs.uploadRiver.fileList.splice(0, 1); // 如果文件超过1个，只保留最后一个
      // }

      this.delRiverData.files = fileList.map(item => item.response.result.path)
    },
    handleError() {
      this.$Message.warning({
        content: '上传失败',
      });
    },
     // 删除河流
    delRiver () {
      let params = {
        data: this.delRiverData,
        url: this.urlLakeDel,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code == '0000') {
            this.$Message.success({
              content: res.data.message
            });
            this.hideRiverModal()
            this.getData();
          } else {
            this.$Message.warning({
              content: res.data.message,
            });
          }
        },
      }
      ajaxPost(params);
    },
    // 取消保存删除河流文件
    hideRiverModal() {
      this.$refs.uploadRiver && this.$refs.uploadRiver.clearFiles();
      this.delRiverData = [];
      this.riverModal = false;
    },
    clear_map() {
      this.bigArr_gcj02 = [];
      this.latArr_gcj02 = [];
      this.chongHui = false;
      let maps = document.getElementById('riverMap');
      maps.innerHTML = '';
      let center = new qq.maps.LatLng(23.009912294150357, 113.12484741210938);
      map1 = new qq.maps.Map(maps, {
        center,
        zoom: 10,
      });
      let path1 = [];
      listener = qq.maps.event.addListener(map1, 'click', event => {
        let cirle = new qq.maps.Circle({
          center: new qq.maps.LatLng(
            event.latLng.getLat(),
            event.latLng.getLng()
          ),
          radius: 4,
          fillColor: '#ff0000',
          map: map1,
        });
        path1.unshift(
          new qq.maps.LatLng(event.latLng.getLat(), event.latLng.getLng())
        );
        let polyline = new qq.maps.Polyline({
          path: path1,
          strokeColor: '#ff0000',
          strokeWeight: 3,
          editable: false,
          map: map1,
        });
        this.latArr_gcj02.push({
          lat: event.latLng.getLat(),
          lng: event.latLng.getLng(),
        });
      });
    },
    addRiver() {
      qq.maps.event.removeListener(listener);
      if (gm > 0) {
        qq.maps.event.removeListener(listener2);
      }
      let path1 = [];
      listener2 = qq.maps.event.addListener(map1, 'click', event => {
        let cirle = new qq.maps.Circle({
          center: new qq.maps.LatLng(
            event.latLng.getLat(),
            event.latLng.getLng()
          ),
          radius: 4,
          fillColor: '#ff0000',
          map: map1,
        });
        path1.unshift(
          new qq.maps.LatLng(event.latLng.getLat(), event.latLng.getLng())
        );
        let polyline = new qq.maps.Polyline({
          path: path1,
          strokeColor: '#ff0000',
          strokeWeight: 3,
          editable: false,
          map: map1,
        });
        this.latArr_gcj02.push({
          lat: event.latLng.getLat(),
          lng: event.latLng.getLng(),
        });
      });
      this.bigArr_gcj02.push(this.latArr_gcj02);
      this.latArr_gcj02 = [];
      gm++;
    },
    changeRoute() {
      if (this.latArr_gcj02.length != 0) {
        this.bigArr_gcj02.push(this.latArr_gcj02);
      }
      let params = {
        data: {
          river_name: this.saveRow.river_name,
          river_no: this.saveRow.river_no,
          big_gcj02: this.bigArr_gcj02,
        },
        url: this.urlRouteEdit,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code == '0000') {
            this.$Loading.finish();
            this.$Message.success({
              content: '修改成功',
            });
            this.edit(this.saveRow);
            this.chongHui = true;
          } else {
            this.$Message.warning({
              content: res.data.message,
            });
          }
        },
      };
      ajaxPost(params);
    },
  },
  mounted() {
    this.getData();
    this.getAddress();
  },
  watch: {
    area(data) {
      let i = data.length - 1;
      this.getReceive(data[i]);
    },
    'lakeItem.area'(data) {
      this.getTown(data);
    },
  },
};
</script>
